package models;

import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Query;

import models.validation.AdminUserValidator;

import play.data.validation.CheckWith;
import play.data.validation.Email;
import play.data.validation.MinSize;
import play.data.validation.Password;
import play.data.validation.Required;
import play.db.jpa.GenericModel;
import play.db.jpa.Model;

@Entity
public class AdminUser extends GenericModel {
	
	/* Variable Definitions */
	
	@Id
	@CheckWith(value = AdminUserValidator.class, message = "Existing admin user has been found with this username")
	private String username;
	
	@Required
	@MinSize(5)
	@Password
	private String password;
	
	@Required
	@Email
	private String email;
	
	/* End of Variable Definitions */
	
	
	/* Getter and Setter Methods */
	
	// -- name section --
	
	public String getUsername() {
		return username;
	}
	
	public void setUsername(String username) {
		this.username = username;
	}
	
	public String getPassword() {
		return password;
	}
	
	public void setPassword(String password) {
		this.password = password;
	}
	
	public String getEmail() {
		return email;
	}
	
	public void setEmail(String email) {
		this.email = email;
	}
	
	/* End of Getter and Setter Methods */
	
	
	/* Other Methods */
	
	@Override
	public String toString() {
		return username;
	}
	
	public static boolean isExist(String value) {
		return AdminUser.find("byUsername", value) != null;
	}
	
	/* End of Other Methods */
	
}